<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=8">

    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>增加分发群组</title>
    <link rel="stylesheet" th:href="@{/layui/layui/css/layui.css}">

</head>
<body>
<br />

<div class="layui-form-item">
    <div class="layui-inline">
        <label class="layui-form-label">群组名称</label>
        <div class="layui-input-inline">
            <input id="groupname"  style="width: 250px;" type="tel" name="groupname" lay-verify="required|phone" autocomplete="off" class="layui-input">
        </div>
    </div>
    <form class="layui-form">
        <label class="layui-form-label">所属存储源</label>
        <div class="layui-input-inline" style="width: 250px;">
            <select id="keyid"  name="quiz1" style="max-height: 360px;">
                <option value="5">&nbsp;本地存储</option>
                <option value="1">&nbsp;网易NOS</option>
                <option value="2">&nbsp;阿里OSS</option>
                <option value="3">&nbsp;又拍USS</option>
                <option value="4">&nbsp;七牛云KODO</option>
                <option value="6">&nbsp;腾讯COS</option>
                <option value="7">&nbsp;FTP存储</option>
            </select>
        </div>
    </form>
    <br/><br/><button type="button" style="float: right;margin-right: 65px;" class="layui-btn layui-btn-radius layui-btn-normal" onclick="addgroup()">保 存</button>
</div>


<script th:src="@{/static/js/jquery-3.4.1.min.js}" type="text/javascript"></script>
<script th:src="@{/layui/layui/layui.js}"></script>
<script>
    layui.use(['form','table','layer'], function(){
        table = layui.table;
        var layer = layui.layer;
        var form = layui.form;


    });
function delectcode(code) {
    var index= layer.msg('加载中', {
        icon: 16
        ,shade: 0.01
    });
    $.ajax({
        type: "POST",
        url: "/admin/root/deletecode",
        data: {code:code},
        dataType: "json",
        success: function (data) {
            if (data > 0) {
                table.reload('datas');//重新获取表数据
                layer.msg('删除成功', {icon: 1});
            }else{
                layer.msg('部分数据可能未删除成功', {icon: 2});
            }
        }
    });
    layer.close(index);
}


function addgroup() {
    layer.msg('加载中', {
        icon: 16
        ,shade: 0.01
    });
    var groupname = $('#groupname').val();
    var keyid = $('#keyid').val();
    $.ajax({
        type: "POST",
        url: "/admin/root/addisgroup",
        data: {groupname:groupname,keyid:keyid},
        dataType: "json",
        success: function (data) {
            if (data > 0) {
                table.reload('datas');//重新获取表数据
                layer.msg('添加成功', {icon: 1});
            }else if(data==-1){
                layer.msg('该存储源配置不完整，请先将存储源配置填写完整再操作', {icon: 2});
            }else{
                layer.msg('添加失败', {icon: 2});
            }
        }
    });
    layer.closeAll();
}

</script>
</body>
</html>